package com.yq.skinlib.sizechange;


import com.yq.skinlib.observe.SkinObservable;
import com.yq.skinlib.utils.SkinPreference;

/**
 * 创建者     Maggie
 * 创建时间   2019/3/20 2:40 PM
 * 描述	     动态修改字号管理类
 * <p>
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${}
 */
public class ChangeTextSizeManager extends SkinObservable {
    private float textSize = 1;

    private static volatile ChangeTextSizeManager               sInstance;

    public static ChangeTextSizeManager init() {
        if (sInstance == null) {
            synchronized (ChangeTextSizeManager.class) {
                if (sInstance == null) {
                    sInstance = new ChangeTextSizeManager();
                }
            }
        }
        return sInstance;
    }

    public static ChangeTextSizeManager getInstance() {
        return sInstance;
    }


    public void changeTextSize(float textsize){
        setTextSize(textsize);
        notifyUpdateTextSize();
    }

    private ChangeTextSizeManager() {
        textSize = SkinPreference.getInstance().getTextSize();
    }

    public float getTextSize() {
        return textSize;
    }

    public void setTextSize(float textSize) {
        this.textSize = textSize;
        SkinPreference.getInstance().setTextSize(textSize).commitEditor();
    }
}
